﻿using System;
using System.Text;
using BruteForceSerializer.Tests.TestClasses;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace BruteForceSerializer.Tests
{
    [TestClass]
    public class test_Serializer
    {
		[TestMethod]
		public void Integrationstest_Serialize()
		{
			var sut = new Serializer();

			var text = sut.Serialize(42);

			Assert.AreEqual(@"{""_Id"":0,""_Type"":""int"",""value"":42}", text);
		}

		[TestMethod]
		public void Integrationstest_Deserialize()
		{
			var sut = new Serializer();

			var obj = sut.DeSerialize(@"{
  ""_Id"": 0,
  ""_Type"": ""int"",
  ""value"": 42
}");
			Assert.AreEqual(42, obj);
		}

		[TestMethod]
        public void Null_kann_serialisiert_werden() {
            var sut = new Serializer();

            var text = sut.Serialize(null);


            Assert.AreEqual("null", text);
        }

		[TestMethod]
		public void Integrationstest_ComplexClass()
		{
			var sut = new Serializer();

			var obj = new KlasseMitCollections();
			string serialized = sut.Serialize(obj);
			//var bytes = Encoding.UTF8.GetBytes(serialized);
			Console.WriteLine(serialized);
			var obj2 = sut.DeSerialize(serialized);
			Assert.IsNotNull(obj2);
		}
    }
}